package de.jmda.core.mproc.task;

import java.lang.annotation.Annotation;
import java.util.Set;

import javax.lang.model.element.Element;

import de.jmda.core.util.fileset.FileSet;

/**
 * Base class for {@link Task}s that are targeted to the {@link Element}s that
 * are annotated with at least one of the annotation types specified in
 * {@link #annotationTypes}.
 *
 * @author roger@jmda.de
 */
public abstract class AbstractAnnotatedElementsTask extends AbstractTask
{
	private Set<Class<? extends Annotation>> annotationTypes;
	private FileSet fileset;

	public AbstractAnnotatedElementsTask(
			Set<Class<? extends Annotation>> annotationTypes, FileSet fileset)
  {
	  super();

	  if (annotationTypes == null)
	  {
	  	throw new IllegalArgumentException(
	  			"can not run annotation task without annotations");
	  }
	  
	  if (annotationTypes.size() == 0)
	  {
	  	throw new IllegalArgumentException(
	  			"can not run annotation task without annotations");
	  }
	  
	  if (fileset == null)
	  {
	  	throw new IllegalArgumentException(
	  			"can not run annotation task without fileset");
	  }

	  this.annotationTypes = annotationTypes;
	  this.fileset = fileset;
  }

	public Set<Class<? extends Annotation>> getAnnotationTypes()
	{
		return annotationTypes;
	}

	public FileSet getFileset()
	{
		return fileset;
	}
}